package com.wuxl.web.controller;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@Slf4j
public class TestController {

    @GetMapping("/test/get")
    public String testGet(HttpServletRequest req, HttpServletResponse resp,@RequestParam(required = false) String phone){
        log.info("get请求参数：phone:{}", phone);
        return "test get succ";
    }

    @GetMapping("/test/get/a")
    public String testGet1(HttpServletRequest req, HttpServletResponse resp){
        return "test get a succ";
    }

    @GetMapping("/test/get/b")
    public String testGet2(HttpServletRequest req, HttpServletResponse resp){
        return "test get b succ";
    }

    @PostMapping("/test/post")
    public String testPot(HttpServletRequest req, HttpServletResponse resp, @RequestBody Map<String,String> body){
        log.info("post请求参数：{}", JSON.toJSONString(body));
        return "test post succ";
    }
}
